import Vue from 'vue'
import request from '@/itsoftUI/utils/request'
import qs from "qs"
const baseUrl = Vue.prototype.$serviceUrl + "/repairInspection"

//数据字典api
export const equipmentApi = {
  //获取导入字段定义列表数据
  ImportList: function (search, order) {
    const data = {
      search, order
    }
    return request({
      url: baseUrl + '/importData/list',
      method: 'post',
      data: qs.stringify(data)
    })
  },
  //设备数据导入
  ImportDeviceInfo: function (dataList, queryList, pageIndex, totalPages) {
    const data = {
      dataList, queryList, pageIndex, totalPages
    }
    return request({
      url: baseUrl + '/importData/importDeviceInfo',
      method: 'post',
      data: qs.stringify(data)
    })
  },
  //设备信息导入前验证
  ImportDeviceInfoValidate: function (dataList, queryList, pageIndex, totalPages) {
    const data = {
      dataList, queryList, pageIndex, totalPages
    }
    return request({
      url: baseUrl + '/importData/importDeviceInfoValidate',
      method: 'post',
      data: qs.stringify(data)
    })
  },
  // regionInfo/getRegionTree
  // 区域树
  getRegionTree: function () {
    return request({
      url: baseUrl + '/regionInfo/getRegionTree',
      method: 'post',
    })
  },
  // 数据字典
  systemDictData: function (search, order) {
    const data = {
      search, order
    }
    return request({
      url: baseUrl + '/systemDictData/list',
      method: 'post',
      data: qs.stringify(data)
    })
  },
  // 维修记录
  repairList: function (page, search, order) {
    const data = {
      page, search, order
    }
    return request({
      url: baseUrl + '/deviceRepairLog/list',
      method: 'post',
      data: qs.stringify(data)
    })
  },
  // 保存巡检人员或管理人员
  batchSavedeviceUser: function (ids, type, regionUserList) {
    const data = {
      ids, type, regionUserList
    }
    return request({
      url: baseUrl + '/deviceUser/batchSaveDeviceUser',
      method: 'post',
      data: qs.stringify(data)
    })

  },
  // 删除人员
  deleteDeviceUser: function (id, userId) {
    const data = {
      id, userId
    }
    return request({
      url: baseUrl + '/deviceUser/deleteDeviceUser',
      method: 'post',
      data: qs.stringify(data)
    })
  },
  // 用户
  userList: function (search, order) {
    const data = {
      search, order
    }
    return request({
      url: Vue.prototype.$serviceUrl + '/auth/user/list',
      method: 'post',
      data: qs.stringify(data)
    })
  },
  // 保存巡检人员或管理人员
  saveDeviceUser: function (data) {
    const config = {
      headers: {
        'Content-Type': 'application/json;charset=utf-8'
      },
    }
    return request.post(baseUrl + "/deviceUser/saveDeviceUser", data, config)
  },
  List: function (page, search, fields, order) {
    const data = {
      page, search, fields, order
    }
    return request({
      url: baseUrl + '/deviceInfo/list',
      method: 'post',
      data: qs.stringify(data)
    })
  },
  codeList: function (search, fields, order) {
    const data = {
      search, fields, order
    }
    return request({
      url: baseUrl + '/deviceInfo/list',
      method: 'post',
      data: qs.stringify(data)
    })
  },
  //提取信息
  Get: function (id) {
    const data = {
      id
    };
    return request({
      url: baseUrl + "/deviceInfo/get",
      method: "post",
      data: qs.stringify(data)
    });
  },
  //提取信息
  GetRepair: function (id) {
    const data = {
      id
    };
    return request({
      url: baseUrl + "/deviceRepairLog/get",
      method: "post",
      data: qs.stringify(data)
    });
  },
  DelRepair: function (ids) {
    const data = {
      ids
    }
    return request({
      url: baseUrl + "/deviceRepairLog/delete",
      method: "post",
      data: qs.stringify(data)
    });
  },
  // 删除
  Del: function (ids) {
    const data = {
      ids
    }
    return request({
      url: baseUrl + "/deviceInfo/delete",
      method: "post",
      data: qs.stringify(data)
    });
  },
  saveRepair: function (data) {
    const config = {
      headers: {
        'Content-Type': 'application/json;charset=utf-8'
      },
    }
    return request.post(baseUrl + "/deviceRepairLog/save", data, config)
  },
  save: function (data) {
    const config = {
      headers: {
        'Content-Type': 'application/json;charset=utf-8'
      },
    }
    return request.post(baseUrl + "/deviceInfo/save", data, config)
  }
}